package com.zzyl.serve.controller;

import cn.hutool.db.Page;
import com.zzyl.common.core.controller.BaseController;
import com.zzyl.common.core.domain.AjaxResult;
import com.zzyl.common.core.page.TableDataInfo;
import com.zzyl.serve.domain.NursingTask;
import com.zzyl.serve.dto.NursingTaskDto;
import com.zzyl.serve.dto.TaskDto;
import com.zzyl.serve.service.INursingTaskService;
import com.zzyl.serve.vo.NursingTaskVo;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
@RequestMapping("/nursing/nursingTask")
@RestController
public class NursingTaskController extends BaseController {

    @Autowired
    private INursingTaskService nursingTaskService;


    @GetMapping("/list")
    public TableDataInfo list(NursingTaskDto nursingTaskDto){
//        startPage();
        TableDataInfo list = nursingTaskService.selectNursingTaskList(nursingTaskDto);
        return list;
    }
    @GetMapping("/{id}")
    public AjaxResult selectNursingTaskById(@PathVariable Long id){
        NursingTaskVo nursingTaskVo = nursingTaskService.selectNursingTaskById(id);
        return AjaxResult.success(nursingTaskVo);
    }
    //取消任务
    @ApiOperation("取消任务")
    @PutMapping("/cancel")
    public AjaxResult cancelTask(@ApiParam(value = "护理任务实体", required = true) @RequestBody TaskDto taskDto) {
        return toAjax(nursingTaskService.cancelTask(taskDto));
    }


    //任务执行
    @ApiOperation("任务执行")
    @PutMapping("/do")
    public AjaxResult executeTask(@ApiParam(value = "护理任务实体", required = true) @RequestBody TaskDto taskDto) {
        return toAjax(nursingTaskService.executeTask(taskDto));
    }

    //任务改期
    @ApiOperation("任务改期")
    @PutMapping("/updateTime")
    public AjaxResult rescheduleTask(@ApiParam(value = "护理任务实体", required = true) @RequestBody TaskDto taskDto) {
        return toAjax(nursingTaskService.rescheduleTask(taskDto));
    }
}
